import torch
import torchvision
from torch.nn import Conv2d
from torch.utils.data import DataLoader
from torch.utils.tensorboard import SummaryWriter

test_data = torchvision.datasets.CIFAR10("./dataset_2",train=False,transform=torchvision.transforms.ToTensor(),download=True)
test_data_loader = DataLoader(test_data,64)
writer = SummaryWriter("conv2d_log")

class MyNN(torch.nn.Module):
    def __init__(self):
        super(MyNN, self).__init__()
        self.conv1 = Conv2d(in_channels=3,out_channels=6,kernel_size=3,stride=1,padding=0)

    def forward(self,x):
        return self.conv1(x)

my_nn = MyNN()
step = 1
for data in test_data_loader:
    imgs,lables = data
    # print(imgs.shape)
    output = my_nn(imgs)
    # print(output.shape)

    writer.add_images("input",imgs,step)
    output = torch.reshape(output,(-1,3,30,30))
    # print(output.shape)
    writer.add_images("output",output,step)
    step= step+1

